<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>自定义指令</title>
  <style>

  </style>
</head>

<body>
  <div id="app">
    <h1 v-bgcolor="'red'" v-color="'blue'">11111</h1>
    <h1 v-fontsize="'50px'">22222</h1>
  </div>
  <script src="../vue.js"></script>
  <script>
    Vue.directive('fontsize', (el, binding) => {
      console.log(el, binding.value);
      el.style.fontSize = binding.value
    })

    const vm = new Vue({
      el: "#app",
      directives: {   // 局部指令
        bgcolor(el, binding) {
          el.style.backgroundColor = binding.value
          // console.log(el, binding.value);  
        },
        color: {   // 不常用
          inserted(el, binding) {
            el.style.color = binding.value
          },

        }
      }
    })
  </script>
</body>

</html>